import { Component, OnInit, Input } from '@angular/core';

import { AlertController } from '@ionic/angular';

import { HttpService } from 'src/app/shared/service/http.service';
import { AppGlobalService } from 'src/app/shared/service/app-global.service';

@Component({
  selector: 'app-laijian-shop-posterinfo',
  templateUrl: './laijian-shop-posterinfo.component.html',
  styleUrls: ['./laijian-shop-posterinfo.component.scss'],
})
export class LaijianShopPosterinfoComponent implements OnInit {
  @Input() tagData: any;
  constructor(
    private alertController: AlertController,
    private http: HttpService,
    private appGlobalService: AppGlobalService
  ) { }
  ngOnInit() {
  }

  async call(mobile) {
    const alert = await this.alertController.create({
      header: this.tagData.data.nick_name,
      message: '铺铺旺 ' + mobile,
      buttons: [
        {
          text: '取消',
          role: 'cancel',
          cssClass: 'secondary'
        }, {
          text: '拨打',
          handler: () => {
            this.http.changeCallNumber(mobile);
          }
        }
      ]
    });
    await alert.present();
  }

  publish(item) {
    if (item) {
      const sessionId = localStorage.getItem("sessionId");
      const pageParams = {
        pageId: item.target,
        params: item.params,
        sessionId,
      };
      this.appGlobalService.goToForward(pageParams);

    }

  }

}

